<?php
namespace App\Modules\Relationship\Models;


use App\Http\Services\CommonServices;
use App\Modules\Relationship\Interfaces\ModelInterface;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use App\Http\Model\Base;

class CouplingRingRecordLogModel extends Base {

    // 戒指类型（0-经典戒指,1-荣誉戒指,2-等级戒指,3-其他戒指）
    protected $table = "coupling_ring_record_log";
    protected $fields = ['log_id as logId', 'user_id as userId', 'ring_id as ringId',
        'type', 'desc', 'expire_time as expireTime', 'created_at as createdAt', 'is_deleted as isDeleted'
    ];

    public function __construct(array $attributes = [])
    {
        parent::__construct($this->table, $attributes);
        $this->tablePrefix = env('DB_PREFIX');
    }


    // 写入用户戒指记录表
    public function insert($userId, $ringId, $type=0, $expireTime = 0) {
            DB::table($this->table)->insert([
                'user_id' => $userId,
                'ring_id' => $ringId,
                'desc' => '戒指获得',
                'type' =>$type,
                'expire_time' => $expireTime,
                'created_at'=>time()
            ]);
    }

}